﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Xcj.Mes.WholeLine.ZH.HG.Shell.Converter
{
    public class BeltFillConverter : IValueConverter
    {
        public readonly static string[] colors = new string[]
        {
            "White",     "Green",     "Yellow",        "Red",
            "Black",     "Blue",      "SteelBlue",     "Brown",
            "Magenta",   "LightGray", "Orange",        "Pink",
            "Salmon",    "Violet",    "PaleVioletRed", "Aqua",
            "Chocolate", "Cyan",      "Gold",          "OrangeRed"
        };

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return "Transparent";

            try
            {
                int result = int.Parse(value.ToString());
                if((result >= 0) && (result < colors.Length))
                    return colors[result];
            }
            catch 
            {
            }

            return "Transparent";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
